import router from "@/router";
import { useUserStoreHook } from "@/store/modules/user";
import { usePermissionStoreHook } from "@/store/modules/permission";

import NProgress from "nprogress";
import "nprogress/nprogress.css";
NProgress.configure({ showSpinner: false }); // 进度条

const permissionStore = usePermissionStoreHook();

// 白名单路由
const whiteList = ["/editor"];

router.beforeEach(async (to, from, next) => {
  NProgress.start();
  if(to.query && to.query.url && to.query.appid){
	  next();
	  NProgress.done();
  }
  else{
	  if (whiteList.indexOf(to.path) !== -1) {
	    next();
		NProgress.done();
	  } else {
	    next('/editor');
	    NProgress.done();
	  }
  }
});

router.afterEach(() => {
  NProgress.done();
});
